package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.BaseIdDTO;
import top.hcode.hoj.pojo.dto.QuerySampleDTO;
import top.hcode.hoj.pojo.entity.org.OrgClass;
import top.hcode.hoj.service.admin.AdminOrgClassService;

/**
 * @author orangej
 * @since 2025-02-14
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminOrgClassController {

    private final AdminOrgClassService orgClassService;

    @GetMapping("/admin/org-class/list")
    public CommonResult<IPage<OrgClass>> getOrgClassList(QuerySampleDTO querySampleDTO) {
        return CommonResult.successResponse(orgClassService.getOrgClassList(querySampleDTO));
    }

    @PostMapping("/admin/org-class/save")
    public CommonResult<OrgClass> saveOrgClass(@RequestBody OrgClass orgClass) {
        return CommonResult.successResponse(orgClassService.saveOrgClass(orgClass));
    }

    @PostMapping("/admin/org-class/delete")
    public CommonResult<Void> deleteOrgClass(@RequestBody BaseIdDTO dto) {
        orgClassService.deleteOrgClass(dto.getId());
        return CommonResult.successResponse();
    }

}
